const ci = require('miniprogram-ci');

const appid = process.argv[2];
const privateKey = process.argv[3];
const version = process.argv[4];
const desc = process.argv[5];
(async () => {
  try {
    const project = new ci.Project({
      appid: appid,
      type: 'miniProgram',
      projectPath: 'dist/weapp',
      privateKeyPath: privateKey,
      ignores: ['node_modules/**/*'],
    });
    const uploadResult = await ci.upload({
      project,
      version: version,
      desc: desc,
      setting: {
        minify: true,
      },
      onProgressUpdate: console.log,
    });
    console.log('result--->', uploadResult);
  } catch (e) {
    process.exitCode = 1;
    console.log('build fail:', e);
    throw e;
  }
})();
